package br.com.pyramides.controller;

import br.com.pyramides.facade.UsuarioFacade;
import br.com.pyramides.facade.iface.IUsuarioFacade;
import br.com.pyramides.model.Usuario;
import br.com.pyramides.utils.Constants;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;

/**
 *
 * @author Lessandro
 */
public class UsuarioAction extends DispatchAction {
    
    private Log logger = LogFactory.getLog(this.getClass());
    private IUsuarioFacade usuarioService;
    
    public ActionForward getUsuarios(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
        logger.debug("getUsuarios");
        usuarioService = new UsuarioFacade();
        List<Usuario> usuarios = usuarioService.buscaTodos();
        request.setAttribute(Constants.USUARIOS, usuarios);
        return mapping.findForward(Constants.SUCCESS);
    }
    
}
